/*
 * @Author: your name
 * @Date: 2021-07-06 10:36:40
 * @LastEditTime: 2021-07-06 12:51:30
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \FUDAN\task2\task2.cpp
 */
#include<iostream>
#include<string>
#include <vector>
#include <sstream>
using  namespace std ;
void SplitString(const string& s, vector<string>& v, const string& c)
{
    string::size_type pos1, pos2;
    pos2 = s.find(c);
    pos1 = 0;
    while(string::npos != pos2)
    {
        v.push_back(s.substr(pos1, pos2-pos1));
         
        pos1 = pos2 + c.size();
        pos2 = s.find(c, pos1);
    }
    if(pos1 != s.length())
        v.push_back(s.substr(pos1));
}
void inputToVec(vector<vector<int> > &vvi)
{
vector<string> vs;
string input;
getline(cin,input);
// cout <<input.size()<<endl;
vs.push_back(input);
for (int i = 0;i<input.size()/2;++i)
{   getline(cin,input);
    vs.push_back(input);
}


for (auto i : vs)
{

    vector<string> temp;
    vector<int> vi;
    SplitString(i,temp," ");
    
    for(auto i :temp)
    {
        // cout<<"temp"<<i<<endl;

            int val;
        //     ss<<i;
        // ss>>val;
        val=stoi(i);
        vi.push_back(val);
        // cout<<val<<",";
    
    }
    // cout<<endl;
    vvi.push_back(vi);
}
}
int main(){
vector<vector<int> > vvi ;
inputToVec(vvi);
// vvi={{1,5,1},{1,6,1},{2,3,1}};
int N =vvi[0].size();
vector<vector<int> > sum(N,vector<int>(N,0));
for(int i =0;i<N;++i)
{
    for(int j =0;j<N;++j)
    {
        if(i==0&&j==0)
            sum[0][0]=vvi[0][0];
        else if(j-1<0)
        {
            sum[i][j]=sum[i-1][j]+vvi[i][j];
        }
        else if (i-1<0)
        {
            sum[i][j]=sum[i][j-1]+vvi[i][j];
        }
        else
        {
            sum[i][j]=max(sum[i-1][j],sum[i][j-1])+vvi[i][j];
        }
    }
}
cout << sum[N-1][N-1];
}
